import api from '../../axios/axios';
import type {
  ProblemDetailResponse,
  CodeRunResponse,
  ProblemListResponse,
  ResultExecuteCodeResponse
} from '../../vo/problemDetail';
import type { 
  CodeRunRequest, 
  PageDTO, 
  ExecuteCodeRequest
 } from '../../dto/problemDetail'

// 题目详情相关API
export const problemDetailApi = {
  // 获取题目详情
  getProblemById: (id: string): Promise<ProblemDetailResponse> => {
    return api.get(`/user/problem/${id}`);
  },

  // 获取题目列表
  getProblemList: (data: PageDTO): Promise<ProblemListResponse> => {
    return api.post('/user/problem/list', data, {
    });
  },



  // 运行代码（不计入提交记录）
  runCode: (data: CodeRunRequest): Promise<CodeRunResponse> => {
    return api.post('/run', data);
  },

  // 在线自测代码
  executeCode: (data: ExecuteCodeRequest): Promise<ResultExecuteCodeResponse> => {
    return api.post('/user/judge/execute', data, {
    });
  }
};





export default {
  problemDetailApi
};